This Technical Note describes extensions Apple has defined to ISO 9660 in order to better support Macintosh file interchange. ISO 9660 is an international standard for formatting CD-ROM discs. This tech note is only important if you are a publisher of authoring tools for ISO 9660 discs, or are interested in details of how the Macintosh supports ISO 9660.
Topics
Introduction
It may be desirable to create an ISO 9660 CD ROM containing Macintosh files in order to benefit by the storage capacity and distribution cost savings of CD ROM, and the interchange advantages of ISO 9660. However, the Macintosh file system requires information that the ISO 9660 file system does not support: HFS requires a file type, a file creator, and file attributes.
This document defines a protocol which extends the ISO 9660 specification to include HFS specific information, without corrupting the ISO 9660 structures. Discs created using the protocol are valid ISO 9660 discs, and should not behave differently on non-Apple receiving systems.
The protocol was designed to solve existing compatibility problems as well as allow for future expansion. It uses the SystemIdentifier field in the Primary Volume Descriptor for global information, and the SystemUse field in the directory record for file specific information.
As well as the resource and data forks, additional information is kept about each file. This information is used by the Finder to display the position, attributes, and icon of a file. The additional information consists of a file type of four characters (such as `TEXT' for plain text or unknown type documents, `APPL' for applications, `MACA' for MacWrite documents, and so forth), a file creator unique to each application (such as `MWRT', `EXCL', `FNDR') and file attributes (such as invisible, system file, or locked against accidental deletion.) The additional information also includes a mapping of file creator to appropriate application, so that a Macintosh user may select a document and open it, and the appropriate application will be invoked and passed the document name.
If a ISO 9660 disc has been pressed without the Apple extensions, all files on the disc are considered to be of type `TEXT' and creator `hscd'. Type `TEXT' is a generic type which can be read successfully by many Macintosh applications.
byte DirectoryRcdLength byte XARlength struct ExtentLocation struct DataLength struct RecordingDateTime byte FileFlags byte FileUnitSize byte InterleaveGapSize long VolumeSequenceNum byte FileNameLength char FileName[FileNameLength] byte RecordPad (if necessary) char SystemUse[SystemUseLength] byte RecordPad (if necessary)The RecordPad field is present only if needed to make DirectoryRcdLength an even number. If present, the RecordPad field must be zero ($00). The SystemUse field is an optional field under ISO 9660; it is defined for our use below. The SystemUse field, when present, must begin with a signature word , followed by a one byte length and a one byte SystemUseID, followed by file system specific information. This structure may be repeated multiple times for multiple file systems; however, the total length of the SystemUse area (SystemUseLength) must be an even number. The signature word allows a receiving system to ensure that it can interpret the following data correctly, and the SystemUseID determines the type and format of the information which follows.
CD-ROM XA discs must be handled as a special-case in that the signature word, if present, will begin at byte 14 of the SystemUse field rather than at byte 0.
There are two AppleSignatures. The preferred AppleSignature is defined as "AA" ($41 41). The old AppleSignature, used for a previous version of this document, was defined as "BA" ($42 41). The old AppleSignature is the only one supported by the Macintosh AppleCD SC software version 2.0. Disks pressed using the old format are still supported, but we recommend that new disks be pressed using only the current format.
Receiving systems must perform a simple calculation to determine if the SystemUse field is present in any given directory record. It is present if:
DirectoryRcdLength - FileNameLength > 34Receiving systems should first verify that the SystemUse field is present (making sure to account for the possibility of a RecordPad field), then check for the AppleSignature before interpreting the SystemUseID. The SystemUseID is defined as follows for an AppleSignature of "AA". This is the version of the Apple Extensions that is supported by future versions of the Macintosh AppleCD SC software.
SystemUseID Definition
$00 reserved.
$01 ProDOS file_type and aux_type follow.
$02 HFS fileType, fileCreator, finder flags
$03-FF reserved.
The following tables define in detail the data formats for each SystemUseID. The MSB-LSB notation ("MSB" = Most Significant Byte, "LSB" = Least Significant Byte) means that the MSB occupies the lowest address, while LSB-MSB means that the LSB occupies the lowest address.
SystemUseID 01, ProDOS: SystemUse offset Contents
$00-01 $41 41 (AppleSignature)
$02 SystemUse Extension length ($07 for this ID, includes AppleSignature bytes)
$03 $01 (SystemUseID)
$04 ProDOS file type
$05-06 ProDOS aux type (LSB-MSB)
Note that a padding byte must be added if this ID is the only extension added to the directory record.
SystemUseID 02, HFS: SystemUse offset Contents
$00-$01 $41 $41 (AppleSignature)
$02 SystemUse Extension length ($0E for this ID, includes AppleSignature bytes)
$03 $02 (SystemUseID)
$04-$07 HFS fileType (MSB-LSB)
$08-$0B HFS fileCreator (MSB-LSB)
$0C-$0D HFS finder flags (MSB-LSB)
The SystemUseID is defined as follows for an AppleSignature of "AA". This is the version of the Apple Extensions that is supported by the Macintosh AppleCD SC software version 2.0.
SystemUseID Definition
$00 reserved.
$01 ProDOS file_type and aux_type follow.
$02-05 obsolete versions of HFS; do not use
$06 HFS fileType, fileCreator, finder flags
$07-FF reserved.
The following tables define in detail the data formats for each SystemUseID. The MSB-LSB notation ("MSB" = Most Significant Byte, "LSB" = Least Significant Byte) means that the MSB occupies the lowest address, while LSB-MSB means that the LSB occupies the lowest address.
SystemUseID 01, ProDOS: SystemUse offset Contents
$00-01 $42 41 (AppleSignature)
$02 $01 (SystemUseID)
$03 ProDOS file type
$04-05 ProDOS aux type (LSB-MSB)
SystemUseID 06, HFS: SystemUse offset Contents
$00-$01 $42 $41 (AppleSignature)
$02 $06 (SystemUseID)
$03-$06 HFS fileType (MSB-LSB)
$07-$0A HFS fileCreator (MSB-LSB)
$0B-$0C HFS finder flags (MSB-LSB)
The authoring software can simply copy the finder flags as retrieved by the HFS call PBGetFInfo. Only bits 5 (always switchLaunch), 12 (system file), 13 (bundle bit), and 15 (locked) are used. All other bits are either ignored or set due to internal workings of the file system translator. See Inside Macintosh:Files for more details about the finder flags. There has been some confusion about padding bytes in a directory record which also contains Apple extensions. There are two possible places in a directory record where a padding field may occur: after the File Identifier, and at the end of the directory record. If no Apple extensions exist for a file, then the two locations are identical, and the rule stated in section 9.1.12 applies: "...(a padding field) shall be present ...only if the number in the Length of the File Identifier is an even number." If Apple extensions exist, then section 9.1.13 also applies: "If necessary, so that the Directory Record comprises an even number of bytes, a (00) byte shall be added to terminate this field." (i.e. the System Use field used for Apple extensions.)
BP 3 (LEN_SE): This field shall specify as an 8-bit number the length in bytes of this System Use Extension. This field shall contain an 8-bit number. This field shall be recorded according to 7.1.1. This field shall include the length of the two signature bytes preceeding this byte.
BP 4 to LEN_SE : this field shall be reserved for system use. Its content is not specified by this International Standard.
Multiple System Use Extension fields may exist for a given directory record, subject only to the limitation that the total length of a directory record must be able to be recorded in the 8-bit field defined in section 9.1.1. Note: For CD-ROM XA discs, the Byte Positions listed above must be adjusted upwards by 14 to account for XA's 14 fixed length system use field.
- convert all lowercase characters to uppercase.
- replace all illegal characters, including periods, with underscore ("_", $5F).
- if the filename must be shortened, truncate the rightmost characters.
- if the filename refers to a file, append the characters ".;1" ($2E, 3B, 31).
Following these guidelines will result in more consistent discs.
An associated file is defined as having the associated bit set in the file flags byte of the directory record. It has exactly the same file identifier as its counterpart, and resides immediately before its counterpart in the directory. The associated file is treated as the resource fork, its counterpart is treated as the data fork of the file.
For example, if a file "FOO.;1" has an associated file, there will be two adjacent directory records named "FOO.;1"; the first one (the resource fork) will have the associated bit set, the second one (the data fork) will have the associated bit clear.
Section 13.3.2 of ISO 9660 says, "The implementation [of a receiving system, i.e. one using the CD] shall make available to the user the information that is recorded in each of the descriptor fields listed below." It then follows with a list for various records. For a directory record, the only things listed are file name, file extension, and a bit indicating whether the "file" is a directory. So that's the minimum that an ISO 9660 compliant translator must provide: a file name of the form XXX.YYY with everything specified as uppercase alphanumerics. Section 12.3.1 of ISO 9660 says that a file descriptor includes the file name, file extension, and version number. This means that file descriptors look like FORECAST.DATAFILE;1 (or, for level 1 compliance, FORECAST.DAT;1) Apple's ISO 9660 support included the ";1" as part of the name of the file, because the specification appeared ambiguous, and because the name was valid under the Macintosh OS with the semicolon and version number attached. Subsequent history has shown that this leads to problems with interchanging files with non-Macintosh systems. Starting with CD-ROM software release 5.0, the version number is not displayed unless you hold down the option key while mounting the CD-ROM disc.
/************************************************************************ * * Function: GetFileInfo * * Purpose: get lengths of file rsrc and data forks, type, creator, * and finder flags * * Returns: OSErr * noErr, unless PBGetFInfo has an error. * * Side Effects: rsrcLength, dataLength, fType, fCreator, flags are * updated with correct values for the file requested * * Description: call PBGetFInfo() and return its results. This routine * will only work if the path name to the file on the Mac * can fit in 255 characters (the length of a pascal * string) See Inside Macintosh, Files for more information. * ************************************************************************/ OSErr GetFileInfo(name, vRefNum, rsrcLength, dataLength, fType, fCreator, flags) StringPtr name; short vRefNum; long *rsrcLength; long *dataLength; OSType *fType; OSType *fCreator; short *flags; { HParamBlockRec io; OSErr result; io.fileParam.ioCompletion = 0L; io.fileParam.ioNamePtr = name; io.fileParam.ioVRefNum = vRefNum; io.fileParam.ioFVersNum = 0; io.fileParam.ioFDirIndex = 0; result = PBGetFInfo(&io, false); if (result == noErr) { *rsrcLength = io.fileParam.ioFlRLgLen; *dataLength = io.fileParam.ioFlLgLen; *fType = io.fileParam.ioFlFndrInfo.fdType; *fCreator = io.fileParam.ioFlFndrInfo.fdCreator; *flags = io.fileParam.ioFlFndrInfo.fdFlags; } else { *rsrcLength = 0L; *dataLength = 0L; *fType = 0L; *fCreator = 0L; *flags = 0; } return result; }
1.0 7/7/88 Initial release.
1.1 7/14/88 Removed reference to Macintosh in footnote. Modified note in ProDOS Filename Transformation section to require that Volume Identifier be transformed.
1.2 7/22/88 Changed Protocol Identifier to all uppercase.
1.3 8/2/88 Added SystemUseID 06 for Macintosh Finder flags.
1.4 8/13/88 Corrected location of RecordPad field so comes before the SystemUse field. Added padding fields to SystemUseID's 2-5.
2.0 3/6/89 To accomodate other receiving systems using the SystemUse field, the identification has been slightly modified. A new signature has been added, with some unused fields in the Macintosh extensions removed.
2.1 4/6/89 Described when the Protocol Identifier is required and how to use the extensions on CD-ROM XA discs.
2.2 5/30/89 Corrected SystemUse format description for HFS (SystemUseID 02).
2.3 7/21/89 Added warning about Macintosh versions and what they support. Put back in description of old AppleSignature, for reference.
2.4 2/8/94 Converted to a Technical Note. Previously, this document was "hidden" on the developer CD in a technical report called "CD-ROM and the Macintosh Computer." Removed most ProDOS specific information; it is documented in the Apple IIgs GS/OS Reference from Addison-Wesley.